$(function(){
	$('#login_button').on('click',function(){
		var nameData=$('#loginname').val()
		var passData=$('#password').val()
		if(nameData==''){
			layer.msg('用户名不能为空');
			return false
		}
		if(passData==''){
			layer.msg('密码不能为空');
			return false;
		}
		login_submit(nameData,passData);
	})
})

login_submit=function(nameData,passData){
		var data={"loginname":nameData,"password":passData};
		$.ajax({
			url:baseUrl+'/services/authentication/login',
			type:'POST',
			dataType:'json',
			contentType: "application/json",
			data:JSON.stringify(data),
			success:function(result){
				if(result.errorcode==0){
					layer.msg('登陆成功',1,1);
					localStorage.oauth_token=result.token;
					window.location.href=baseUrl+"/api/special/page/list?ouath_token="+result.token;
				}else layer.msg(result.message)
			}
		
		})
}